package com.eling.elcms.travel.service.impl;

import com.eling.elcms.core.service.impl.GenericManagerImpl;
import com.eling.elcms.travel.dao.INonMemberRegisterDao;
import com.eling.elcms.travel.model.NonMemberRegister;
import com.eling.elcms.travel.service.INonMemberRegisterManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class NonMemberRegisterManagerImpl extends GenericManagerImpl<NonMemberRegister, Long>
		implements INonMemberRegisterManager {

	INonMemberRegisterDao nonMemRegisterDao;

	@Autowired
	public void setNonMemberRegisterDao(INonMemberRegisterDao nonMemRegisterDao) {
		this.dao = nonMemRegisterDao;
		this.nonMemRegisterDao = nonMemRegisterDao;
	}

	@Override
	public List<NonMemberRegister> queryNoExitgroup(NonMemberRegister cond) {
		List<NonMemberRegister> returnList = new ArrayList<>();
		List<NonMemberRegister> nonMemberRegisters = nonMemRegisterDao.query(cond);
		if (!nonMemberRegisters.isEmpty()) {
			for (NonMemberRegister nmr : nonMemberRegisters) {
				if (nmr.getSignUpRegister().getExitGroup() == null || !nmr.getSignUpRegister().getExitGroup()) {
					returnList.add(nmr);
				}
			}
		}
		return returnList;
	}

}
